home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Pascal Super Library
/
Pascal Super Library (CW International)(1997).bin
/
BORL_TIP
/
TI100
/
TI671.ASC
< prev
next >
Wrap
Text File
|
1992-09-03
|
6KB
|
331 lines
PRODUCT : Turbo Pascal NUMBER : 671
VERSION : 6.0
OS : MS/PC DOS
DATE : September 3, 1992 PAGE : 1/5
TITLE : Associating Help Features with Context Hints
{
This program has context help associated with the
WINDOW selection in the main menu. The context help
for the radio buttons in the dialog is supported as
well.
}
{$X+}
program Hints;
uses Objects, Drivers, Views, Menus, Dialogs, App, Gadgets;
const
cmNewDialog = 100;
hcMyDialog = 300;
hcCheck1 = 100; {Declare help context handles}
hcCheck2 = hcCheck1 + 1;
hcRunny = 200;
hcMelted = hcRunny + 1;
type
PMyStatusLine = ^TMyStatusLine;
TMyStatusLine = object(TStatusLine)
function Hint(AHelpCtx : Word) : String; virtual; {Help }
{context}
procedure HandleEvent(var Event : TEvent); virtual;
end;
TMyApp = object(TApplication)
constructor Init;
procedure HandleEvent(var Event: TEvent); virtual;
procedure InitMenuBar; virtual;
procedure InitStatusLine; virtual;
procedure NewDialog;
end;
PDemoDialog = ^TDemoDialog;
TDemoDialog = object(TDialog)
MyStatusLine : PMyStatusLine;
end;
PRODUCT : Turbo Pascal NUMBER : 671
VERSION : 6.0
OS : MS/PC DOS
DATE : September 3, 1992 PAGE : 2/5
TITLE : Associating Help Features with Context Hints
function TMyStatusLine.Hint(AHelpCtx : Word):String;
begin { Load Hint with corresponding menu string}
{ in insertion order }
case AHelpCtx of
hcCheck1 : Hint := 'Tilset Cheese Selection';
hcCheck2 : Hint := 'Jarlsberg Cheese Selection';
hcmyDialog : Hint := 'DIALOG selection now pressed';
hcMelted : Hint := 'Melted Radio Button';
hcRunny : Hint := 'Runny Radio pressed';
else
Hint := '';
end;
end;
procedure TMyStatusLine.HandleEvent(var Event : TEvent);
begin
TStatusLine.HandleEvent(Event);
Update;
end;
constructor TMyApp.Init;
var
R : TRect;
begin
TApplication.Init;
GetExtent(R);
Dec(R.B.X);
R.A.X := R.B.X - 9; R.A.Y := R.B.Y - 1;
end;
{ TMyApp }
procedure TMyApp.HandleEvent(var Event: TEvent);
begin
TApplication.HandleEvent(Event);
if Event.What = evCommand then
begin
case Event.Command of
cmNewDialog: NewDialog;
else
Exit;
end;
ClearEvent(Event);
end;
PRODUCT : Turbo Pascal NUMBER : 671
VERSION : 6.0
OS : MS/PC DOS
DATE : September 3, 1992 PAGE : 3/5
TITLE : Associating Help Features with Context Hints
end;
procedure TMyApp.InitMenuBar;
var
R: TRect;
begin
GetExtent(R);
R.B.Y := R.A.Y + 1;
MenuBar := New(PMenuBar, Init(R, NewMenu(
NewSubMenu('~F~ile', hcNoContext, NewMenu(
NewItem('E~x~it', 'Alt-X', kbAltX, cmQuit, hcNoContext,
nil)),
NewSubMenu('~W~indow', hcNoContext, NewMenu(
NewItem('~D~ialog','F2', kbF2, cmNewDialog, hcmyDialog,
nil)),
nil))
)));
end;
procedure TMyApp.InitStatusLine;
var
R: TRect;
begin
GetExtent(R);
R.A.Y := R.B.Y - 1;
StatusLine := New(PMyStatusLine, Init(R,
NewStatusDef(0,0,
NewStatusKey('', kbF10, cmMenu,
NewStatusKey('~Alt-X~ Exit', kbAltX, cmQuit,
NewStatusKey('~Alt-F3~ Close', kbAltF3, cmClose,
nil))),
NewStatusDef(10,10,
nil,nil))));
end;
procedure TMyApp.NewDialog;
var
Borland: PView;
Dialog: PDemoDialog;
R: TRect;
C: Word;
begin
R.Assign(20, 6, 60, 19);
PRODUCT : Turbo Pascal NUMBER : 671
VERSION : 6.0
OS : MS/PC DOS
DATE : September 3, 1992 PAGE : 4/5
TITLE : Associating Help Features with Context Hints
Dialog := New(PDemoDialog, Init(R, 'Demo Dialog'));
with Dialog^ do
begin
R.Assign(3, 3, 18, 5);
Borland := New(PCheckBoxes, Init(R,
NewSItem('~T~ilset',
NewSItem('~J~arlsberg',
nil)))
);
Borland^.HelpCtx :=hcCheck1;
Insert(Borland);
R.Assign(2, 2, 10, 3);
Insert(New(PLabel, Init(R, 'Cheeses', Borland)));
R.Assign(22, 3, 34, 5);
Borland := New(PRadioButtons, Init(R,
NewSItem('~R~unny',
NewSItem('~M~elted',
nil)))
);
Borland^.HelpCtx := hcRunny;
Insert(Borland);
R.Assign(21, 2, 33, 3);
Insert(New(PLabel, Init(R, 'Consistency', Borland)));
R.Assign(15, 8, 25, 10);
Insert(New(PButton, Init(R, '~O~k', cmOK, bfDefault)));
R.Assign(28, 8, 38, 10);
Insert(New(PButton, Init(R, 'Cancel', cmCancel, bfNormal)));
end;
DeskTop^.ExecView(Dialog);
Dispose(Dialog, Done);
end;
var
MyApp: TMyApp;
begin
MyApp.Init;
MyApp.Run;
MyApp.Done;
end.
PRODUCT : Turbo Pascal NUMBER : 671
VERSION : 6.0
OS : MS/PC DOS
DATE : September 3, 1992 PAGE : 5/5
TITLE : Associating Help Features with Context Hints
DISCLAIMER: You have the right to use this technical information
subject to the terms of the No-Nonsense License Statement that
you received with the Borland product to which this information
pertains.